<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<select>
    <option>请选择</option>
    <option value="0">河北</option>
    <option value="1">山东</option>
    <option value="2">北京</option>
</select>
<select>
    <option>请选择</option>
</select>

<script src="../js/jquery-1.4.2.js"></script>
<script>
    let arr = [["秦皇岛","唐山","石家庄"],
        ["青岛","菏泽","烟台"]
        ["朝阳","东城","大兴"]];
    //给第一个下拉选添加值改变事件
    $("select:first").change(function () {
        //替换原来的内容为 请选择 起到清空作用
        $("select:last").html("<option>请选择</option>");

        //通过点击省份得到的下标，取出数组中对应的城市名
        let cities = arr[this.value];
        //遍历城市数组
        for(let i=0;i<cities.length;i++){
            let name = cities[i];//取出每一个城市的名字
            let o = $("<option></option>");/创建option
            o.text(name);//把城市名装进option
            //把option添加到第二个下拉选中
            $("select:last").append(o);
        }
        // alert(this.value);//弹窗
    });
</script>
</body>
</html>